package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.FocusEvent;
	import flash.events.KeyboardEvent;
	import framework.RobotlegsPlaygroundContext;
	import org.osflash.signals.natives.NativeSignal;
	
	/**
	 * Robot Legs Playground
	 * @author Charlie MacIsaac
	 */
	[SWF(width = "800", height = "600", backgroundColor = "#000000", frameRate = "25")]
	public class RobotlegsPlayground extends Sprite {
		
		private var _context : RobotlegsPlaygroundContext;
		
		public var buttonPressedSignal : NativeSignal;
		public var buttonReleasedSignal : NativeSignal;
		
		private var _focusOutSignal : NativeSignal;
		
		public function RobotlegsPlayground() : void {
			_context = new RobotlegsPlaygroundContext(this);
			
			
			buttonPressedSignal = new NativeSignal(this, KeyboardEvent.KEY_DOWN, KeyboardEvent);
			buttonReleasedSignal = new NativeSignal(this, KeyboardEvent.KEY_UP, KeyboardEvent);
			
			_focusOutSignal = new NativeSignal(this, FocusEvent.FOCUS_OUT, FocusEvent);
			_focusOutSignal.add(refocusToThis);
			refocusToThis();
		}
		
		private function refocusToThis(e : FocusEvent = null) : void {
			stage.focus = this;
		}
	}
}